from flask import Flask

app = Flask(__name__)


@app.route('/')
def index():
    return "index"


@app.route('/index')
def hello_world():
    return "hello world!"


# 127.0.0.1:5000/user?user_id=1
# http://127.0.0.1:5000/user/2
# <user_id> 转换器方式a提取url路径携带的参数，默认提取的是字符串类型数据，即<string:user_id>
@app.route('/<user_id>')
def demo1(user_id):
    return "demo1  %s" % user_id


# http://127.0.0    .1:5000/user_int/2
# <int:user_id>转换器提取url携带的参数，这里为整型转换器，即最后为整型
@app.route('/user_int/<int:user_id>')
def demo2(user_id):
    return "demo2  %d" % user_id


if __name__ == '__main__':
    app.run(debug=True)
